update xs_transaction_t to be a plain u32 integer instead of a fake pointer.
authorvhanquez@kneesa.uk.xensource.com <vhanquez@kneesa.uk.xensource.com>
Wed, 11 Jan 2006 12:01:37 +0000 (12:01 +0000)
committervhanquez@kneesa.uk.xensource.com <vhanquez@kneesa.uk.xensource.com>
Wed, 11 Jan 2006 12:01:37 +0000 (12:01 +0000)
Signed-off-by: Vincent Hanquez <vincent@xensource.com>
14 files changed:
linux-2.6-xen-sparse/arch/xen/kernel/reboot.c
linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c
linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c
linux-2.6-xen-sparse/include/asm-xen/xenbus.h
tools/python/xen/lowlevel/xs/xs.c
tools/xenstat/libxenstat/src/xenstat.c
tools/xenstore/xenstore_client.c
tools/xenstore/xs.c
tools/xenstore/xs.h

index 7a14d8b6cdd8119820c5ae69c85814325a9fa4fe..534c040c101e1ad9e37929288747ccd8b7184832 100644 (file)
@@ -297,8 +297,8 @@ static void shutdown_handler(struct xenbus_watch *watch,
                return;
 
  again:
-       xbt = xenbus_transaction_start();
-       if (IS_ERR(xbt))
+       err = xenbus_transaction_start(&xbt);
+       if (err)
                return;
        str = (char *)xenbus_read(xbt, "control", "shutdown", NULL);
        /* Ignore read errors and empty reads. */
@@ -343,8 +343,8 @@ static void sysrq_handler(struct xenbus_watch *watch, const char **vec,
        int err;
 
  again:
-       xbt  = xenbus_transaction_start();
-       if (IS_ERR(xbt))
+       err = xenbus_transaction_start(&xbt);
+       if (err)
                return;
        if (!xenbus_scanf(xbt, "control", "sysrq", "%c", &sysrq_key)) {
                printk(KERN_ERR "Unable to read sysrq code in "
index c5612ce48b479f81daf4810d3804a6495a858a49..f3a028793599d9421138a99d4a1fe0f3caf38b5b 100644 (file)
@@ -310,10 +310,9 @@ static void connect(struct backend_info *be)
 
        /* Supply the information about the device the frontend needs */
 again:
-       xbt = xenbus_transaction_start();
+       err = xenbus_transaction_start(&xbt);
 
-       if (IS_ERR(xbt)) {
-               err = PTR_ERR(xbt);
+       if (err) {
                xenbus_dev_fatal(dev, err, "starting transaction");
                return;
        }
index 9864ef0a637bfa3c803cae3c707916c6f08f5aa6..3e81abe8e405ea13fce89e5d25b1ff9f7a5f3755 100644 (file)
@@ -170,8 +170,8 @@ static int talk_to_backend(struct xenbus_device *dev,
                goto out;
 
 again:
-       xbt = xenbus_transaction_start();
-       if (IS_ERR(xbt)) {
+       err = xenbus_transaction_start(&xbt);
+       if (err) {
                xenbus_dev_fatal(dev, err, "starting transaction");
                goto destroy_blkring;
        }
index 86798341f41b89b7311ac0c0cd9e02c896ba0f10..f80250d55a3374118a70aba93193091feef05773 100644 (file)
@@ -275,8 +275,8 @@ static int talk_to_backend(struct xenbus_device *dev,
                goto out;
 
 again:
-       xbt = xenbus_transaction_start();
-       if (IS_ERR(xbt)) {
+       err = xenbus_transaction_start(&xbt);
+       if (err) {
                xenbus_dev_fatal(dev, err, "starting transaction");
                goto destroy_ring;
        }
index f93d1c219b1fad359dd132f64ab898b68cf9742b..4a395277110512bcd1a31c0db04065d46915fb79 100644 (file)
@@ -236,9 +236,8 @@ static void connect(struct backend_info *be)
        unsigned long ready = 1;
 
 again:
-       xbt = xenbus_transaction_start();
-       if (IS_ERR(xbt)) {
-               err = PTR_ERR(xbt);
+       err = xenbus_transaction_start(&xbt);
+       if (err) {
                xenbus_dev_fatal(be->dev, err, "starting transaction");
                return;
        }
index 488a17bd6947c66f5224705c3256a40ac171da11..bb4bbe83c0a4d8c0b66438dc975fcef895a8b56f 100644 (file)
@@ -280,8 +280,8 @@ static int talk_to_backend(struct xenbus_device *dev,
        }
 
 again:
-       xbt = xenbus_transaction_start();
-       if (IS_ERR(xbt)) {
+       err = xenbus_transaction_start(&xbt);
+       if (err) {
                xenbus_dev_fatal(dev, err, "starting transaction");
                goto destroy_tpmring;
        }
index 4cfd57c34fba3bbdba641cdcd9a5cf2b0b1a3b82..fc8b22453f9839f2c642b8fd99c43a802ed4212c 100644 (file)
@@ -147,13 +147,11 @@ static ssize_t xenbus_dev_write(struct file *filp,
                }
 
                if (u->u.msg.type == XS_TRANSACTION_START) {
-                       trans->handle = (xenbus_transaction_t)
-                               simple_strtoul(reply, NULL, 0);
+                       trans->handle = simple_strtoul(reply, NULL, 0);
                        list_add(&trans->list, &u->transactions);
                } else if (u->u.msg.type == XS_TRANSACTION_END) {
                        list_for_each_entry(trans, &u->transactions, list)
-                               if ((unsigned long)trans->handle ==
-                                   (unsigned long)u->u.msg.tx_id)
+                               if (trans->handle == u->u.msg.tx_id)
                                        break;
                        BUG_ON(&trans->list == &u->transactions);
                        list_del(&trans->list);
index 98498dcf97998925a83fd3f6982f58128cddc35a..fa404870f1442ae86d8994a234c8125170265b8b 100644 (file)
@@ -201,7 +201,7 @@ static void *xs_talkv(xenbus_transaction_t t,
        unsigned int i;
        int err;
 
-       msg.tx_id = (u32)(unsigned long)t;
+       msg.tx_id = t;
        msg.req_id = 0;
        msg.type = type;
        msg.len = 0;
@@ -424,23 +424,21 @@ EXPORT_SYMBOL(xenbus_rm);
 /* Start a transaction: changes by others will not be seen during this
  * transaction, and changes will not be visible to others until end.
  */
-xenbus_transaction_t xenbus_transaction_start(void)
+int xenbus_transaction_start(xenbus_transaction_t *t)
 {
        char *id_str;
-       unsigned long id;
 
        down_read(&xs_state.suspend_mutex);
 
        id_str = xs_single(XBT_NULL, XS_TRANSACTION_START, "", NULL);
        if (IS_ERR(id_str)) {
                up_read(&xs_state.suspend_mutex);
-               return (xenbus_transaction_t )id_str;
+               return PTR_ERR(id_str);
        }
 
-       id = simple_strtoul(id_str, NULL, 0);
+       *t = simple_strtoul(id_str, NULL, 0);
        kfree(id_str);
-
-       return (xenbus_transaction_t) id;
+       return 0;
 }
 EXPORT_SYMBOL(xenbus_transaction_start);
 
index b6339dbc75f5bc85803bbfa2b98a2522531f43eb..5534fbe99c12fbfe16be1bd3d4c9381639da5a1b 100644 (file)
@@ -37,7 +37,7 @@
 #include <asm-xen/xen-public/io/xenbus.h>
 #include <asm-xen/xen-public/io/xs_wire.h>
 
-#define XBT_NULL NULL
+#define XBT_NULL 0
 
 /* Register callback to watch this node. */
 struct xenbus_watch
@@ -102,8 +102,7 @@ int xenbus_register_frontend(struct xenbus_driver *drv);
 int xenbus_register_backend(struct xenbus_driver *drv);
 void xenbus_unregister_driver(struct xenbus_driver *drv);
 
-struct xenbus_transaction;
-typedef struct xenbus_transaction *xenbus_transaction_t;
+typedef u32 xenbus_transaction_t;
 
 char **xenbus_directory(xenbus_transaction_t t,
                        const char *dir, const char *node, unsigned int *num);
@@ -116,7 +115,7 @@ int xenbus_mkdir(xenbus_transaction_t t,
 int xenbus_exists(xenbus_transaction_t t,
                  const char *dir, const char *node);
 int xenbus_rm(xenbus_transaction_t t, const char *dir, const char *node);
-xenbus_transaction_t xenbus_transaction_start(void);
+int xenbus_transaction_start(xenbus_transaction_t *t);
 int xenbus_transaction_end(xenbus_transaction_t t, int abort);
 
 /* Single read and scanf: returns -errno or num scanned if > 0. */
index 5f6d1850f41fff4b086b409671faa0e20d3e8d34..25dfaaf2a46260ed4904d845c9b0bd0545ad24b7 100644 (file)
@@ -132,7 +132,7 @@ static PyObject *xspy_write(XsHandle *self, PyObject *args)
     if (!PyArg_ParseTuple(args, arg_spec, &thstr, &path, &data, &data_n))
         return NULL;
 
-    th = (xs_transaction_t)strtoul(thstr, NULL, 16);
+    th = strtoul(thstr, NULL, 16);
 
     Py_BEGIN_ALLOW_THREADS
     result = xs_write(xh, th, path, data, data_n);
@@ -264,7 +264,7 @@ static PyObject *xspy_get_permissions(XsHandle *self, PyObject *args)
     if (!PyArg_ParseTuple(args, arg_spec, &thstr, &path))
         return NULL;
 
-    th = (xs_transaction_t)strtoul(thstr, NULL, 16);
+    th = strtoul(thstr, NULL, 16);
 
     Py_BEGIN_ALLOW_THREADS
     perms = xs_get_permissions(xh, th, path, &perms_n);
@@ -320,7 +320,7 @@ static PyObject *xspy_set_permissions(XsHandle *self, PyObject *args)
     if (!PyArg_ParseTuple(args, "ssO", &thstr, &path, &perms))
         goto exit;
 
-    th = (xs_transaction_t)strtoul(thstr, NULL, 16);
+    th = strtoul(thstr, NULL, 16);
 
     if (!PyList_Check(perms)) {
         PyErr_SetString(PyExc_RuntimeError, "perms must be a list");
@@ -519,7 +519,7 @@ static PyObject *xspy_transaction_start(XsHandle *self)
     th = xs_transaction_start(xh);
     Py_END_ALLOW_THREADS
 
-    if (th == NULL) {
+    if (th == XBT_NULL) {
         PyErr_SetFromErrno(PyExc_RuntimeError);
         return NULL;
     }
@@ -556,7 +556,7 @@ static PyObject *xspy_transaction_end(XsHandle *self, PyObject *args,
                                      &thstr, &abort))
         return NULL;
 
-    th = (xs_transaction_t)strtoul(thstr, NULL, 16);
+    th = strtoul(thstr, NULL, 16);
 
     Py_BEGIN_ALLOW_THREADS
     result = xs_transaction_end(xh, th, abort);
@@ -740,7 +740,7 @@ static int parse_transaction_path(XsHandle *self, PyObject *args,
     if (!PyArg_ParseTuple(args, "ss", &thstr, path))
         return 0;
 
-    *th = (xs_transaction_t)strtoul(thstr, NULL, 16);
+    *th = strtoul(thstr, NULL, 16);
 
     return 1;
 }
index 921c7d29dbcc2c89998f2eef7dff2cd46056e349..e8a6928dac194f6fb3eeada55a47b59b17a3af2f 100644 (file)
@@ -705,7 +705,7 @@ static char *xenstat_get_domain_name(xenstat_handle *handle, unsigned int domain
 
        snprintf(path, sizeof(path),"/local/domain/%i/name", domain_id);
        
-       name = xs_read(handle->xshandle, NULL, path, NULL);
+       name = xs_read(handle->xshandle, XBT_NULL, path, NULL);
        if (name == NULL)
                name = strdup(" ");
 
index deb63453d3163b45b142275233855e3686312445..07809e6c8320253dfe86cd27cf95686a905e6939 100644 (file)
@@ -243,7 +243,7 @@ main(int argc, char **argv)
 
   again:
     xth = xs_transaction_start(xsh);
-    if (xth == NULL)
+    if (xth == XBT_NULL)
        errx(1, "couldn't start transaction");
 
     ret = perform(optind, argc, argv, xsh, xth, prefix, tidy);
index 8332e1aad5a19a8f5c1d9bb6603f700532d423f8..f7a576119f8f462a208a94341f6c0245639891d5 100644 (file)
@@ -304,7 +304,7 @@ static void *xs_talkv(struct xs_handle *h, xs_transaction_t t,
        unsigned int i;
        struct sigaction ignorepipe, oldact;
 
-       msg.tx_id = (uint32_t)(unsigned long)t;
+       msg.tx_id = t;
        msg.req_id = 0;
        msg.type = type;
        msg.len = 0;
@@ -634,21 +634,21 @@ bool xs_unwatch(struct xs_handle *h, const char *path, const char *token)
 /* Start a transaction: changes by others will not be seen during this
  * transaction, and changes will not be visible to others until end.
  * You can only have one transaction at any time.
- * Returns NULL on failure.
+ * Returns XBT_NULL on failure.
  */
 xs_transaction_t xs_transaction_start(struct xs_handle *h)
 {
        char *id_str;
-       unsigned long id;
+       xs_transaction_t id;
 
        id_str = xs_single(h, XBT_NULL, XS_TRANSACTION_START, "", NULL);
        if (id_str == NULL)
-               return NULL;
+               return XBT_NULL;
 
        id = strtoul(id_str, NULL, 0);
        free(id_str);
 
-       return (xs_transaction_t)id;
+       return id;
 }
 
 /* End a transaction.
index 55bbcd157ad7cd3edadbb2696a67375e1da6e192..cabf9d0711c8cc0ff4388a6d521ce9f44de02aa3 100644 (file)
 
 #include <xs_lib.h>
 
-#define XBT_NULL NULL
+#define XBT_NULL 0
 
 struct xs_handle;
-struct xs_transaction_t;
-typedef struct xs_transaction_t * xs_transaction_t;
+typedef uint32_t xs_transaction_t;
 
 /* On failure, these routines set errno. */